package com.unknowpupil.design.factory.impl;

/**
 * @Description: 静态构建方法 <br/>
 * <p>
 * 所谓工厂方法就是一种依赖于继承的设计模式。如果设置为static 那么就不能在子类中对其进行宽展。这就破化了改模式的设定
 * <p>
 * 静态构建方法 返回一个新对象时， 它就成为了构造函数的替代品。
 * </p>
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2020/4/24 14:49
 * @Classname: User
 * @Version: 1.0
 */
class User {
    private Integer id;
    private String name, email, phone;

    public User(Integer id, String name, String email, String phone) {
        this.id = id;
        this.name = name;
        this.email = email;
        this.phone = phone;
    }

    public static User load(Integer id) {

        /**
         * 查询数据库
         list($id, $name, $email, $phone) = DB::load_data('users', 'id', 'name', 'email', 'phone');
         $user = new User($id, $name, $email, $phone);
         */
        Integer id1 = null;
        String name1 = null;
        String email1 = null;
        String phone1 = null;
        return new User(id1, name1, email1, phone1);
    }

    public User() {
    }
}